package com.net.common.entity;

import com.net.common.util.DateUtils;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

/**
 * 缓存bean
 *
 * @author hjh
 */
@Setter
@Getter
public class CacheBean {
    /**
     * 缓存时间 3分钟
     */
    public static final int CACHE_TIME = 180000;
    /**
     * 缓存内容
     */
    private byte[] cache;
    /**
     * 过期时间
     */
    private Date expirationTime;
    /**
     * 缓存大小 单位Byte
     */
    private long size;

    public CacheBean(byte[] cache, Date expirationTime, long size) {
        this.cache = cache;
        this.expirationTime = expirationTime;
        this.size = size;
    }

    public CacheBean(byte[] cache) {
        this(cache, DateUtils.addTime(CACHE_TIME), cache.length);
    }
}
